/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Ventanas;

import Reportes.FormatosPDF;
import Ventanas.Administracion.*;
import Ventanas.Cliente.*;
import com.asistencia.DAO.factory.FactoryDAO;
import com.asistencia.model.Funcionario;
import com.asistencia.model.Marcacion;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;

/**
 *
 * @author rfarias
 */
public class Menu extends javax.swing.JFrame {


     static Funcionario funtemp;

    /**
     * Creates new form Menu
     */
    public Menu(Funcionario fun) {
        initComponents();
        this.pnlAdmin.hide();
        funtemp = fun;
        this.lblUsuario.setText(funtemp.getNombres());

        switch (Integer.parseInt(""+funtemp.getPerfil().getId_perfil()))
        {
            case 10:
                this.btnTurno.setEnabled(false);
                break;
            case 20:
                this.pnlAdmin.show();
                this.btnMantAAut.setEnabled(false);
                this.btnMantFun.setEnabled(false);
                this.btnMantMod.setEnabled(false);
                this.btnMantPer.setEnabled(false);
                break;
            case 40:
                this.pnlAdmin.show();
                this.btnMantPer.setEnabled(false);
                this.btnMantMod.setEnabled(false);
                this.btnReporte.setEnabled(false);
                break;
            case 50:
                this.pnlAdmin.show();
                this.btnMantPer.setEnabled(false);
                this.btnReporte.setEnabled(false);
                break;
            case 100:
                this.pnlAdmin.show();
                break;
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        btnMarca = new javax.swing.JButton();
        btnConMar = new javax.swing.JButton();
        btnTurno = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        lblUsuario = new javax.swing.JLabel();
        pnlAdmin = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        btnMantFun = new javax.swing.JButton();
        btnMantMod = new javax.swing.JButton();
        btnMantAAut = new javax.swing.JButton();
        btnAsigTurno = new javax.swing.JButton();
        btnAdminAAut = new javax.swing.JButton();
        btnMantPer = new javax.swing.JButton();
        btnMantTurno = new javax.swing.JButton();
        btnReporte = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SITA - Menú");
        setBounds(new java.awt.Rectangle(200, 200, 0, 0));
        setForeground(java.awt.Color.white);
        setIconImage(new ImageIcon(getClass().getResource("/Ventanas/icono.png")).getImage());
        setIconImages(null);
        setMaximizedBounds(new java.awt.Rectangle(624, 378, 624, 378));

        jLabel1.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Sistema de Turnos Programa Bibliometro");
        jLabel1.setToolTipText("");

        btnMarca.setText("Marcación");
        btnMarca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMarcaActionPerformed(evt);
            }
        });

        btnConMar.setText("Historial Marcado");
        btnConMar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConMarActionPerformed(evt);
            }
        });

        btnTurno.setText("Turnos");
        btnTurno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTurnoActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel2.setText("Usuario Registrado: ");

        lblUsuario.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblUsuario.setToolTipText("");

        pnlAdmin.setBackground(new java.awt.Color(204, 255, 204));

        jLabel3.setFont(new java.awt.Font("Impact", 0, 24)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("ADMINISTRACION");

        btnMantFun.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnMantFun.setText("<html><center>Mantenedor de<br>Funcionarios</center></html>");
        btnMantFun.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnMantFun.setMinimumSize(new java.awt.Dimension(139, 80));
        btnMantFun.setPreferredSize(new java.awt.Dimension(139, 80));
        btnMantFun.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMantFunActionPerformed(evt);
            }
        });

        btnMantMod.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnMantMod.setText("<html><center>Mantenedor de<br>Módulos</center></html>");
        btnMantMod.setMinimumSize(new java.awt.Dimension(139, 80));
        btnMantMod.setPreferredSize(new java.awt.Dimension(139, 80));
        btnMantMod.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMantModActionPerformed(evt);
            }
        });

        btnMantAAut.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnMantAAut.setText("<html><center>Mantenedor de<br>Ausencias Autorizadas</center></html>");
        btnMantAAut.setMinimumSize(new java.awt.Dimension(139, 80));
        btnMantAAut.setPreferredSize(new java.awt.Dimension(139, 80));
        btnMantAAut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMantAAutActionPerformed(evt);
            }
        });

        btnAsigTurno.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnAsigTurno.setText("<html><center>Asignación de<br>Turnos</center></html>");
        btnAsigTurno.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAsigTurno.setMinimumSize(new java.awt.Dimension(139, 80));
        btnAsigTurno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAsigTurnoActionPerformed(evt);
            }
        });

        btnAdminAAut.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnAdminAAut.setText("<html><center>Administración de<br>Ausencias Autorizadas</center></html>");
        btnAdminAAut.setMinimumSize(new java.awt.Dimension(139, 80));
        btnAdminAAut.setPreferredSize(new java.awt.Dimension(139, 80));
        btnAdminAAut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdminAAutActionPerformed(evt);
            }
        });

        btnMantPer.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnMantPer.setText("<html><center>Mantenedor de<br>Perfiles</center></html>");
        btnMantPer.setMinimumSize(new java.awt.Dimension(139, 80));
        btnMantPer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMantPerActionPerformed(evt);
            }
        });

        btnMantTurno.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnMantTurno.setText("<html><center>Mantenedor de<br>Turnos</center></html>");
        btnMantTurno.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnMantTurno.setMinimumSize(new java.awt.Dimension(139, 80));
        btnMantTurno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMantTurnoActionPerformed(evt);
            }
        });

        btnReporte.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnReporte.setText("<html><center>Reporte mensual de Asistencia</center></html>");
        btnReporte.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnReporte.setMinimumSize(new java.awt.Dimension(139, 80));
        btnReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReporteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlAdminLayout = new javax.swing.GroupLayout(pnlAdmin);
        pnlAdmin.setLayout(pnlAdminLayout);
        pnlAdminLayout.setHorizontalGroup(
            pnlAdminLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAdminLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlAdminLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(pnlAdminLayout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(pnlAdminLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlAdminLayout.createSequentialGroup()
                                .addComponent(btnMantPer, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnMantTurno, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnAsigTurno, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlAdminLayout.createSequentialGroup()
                                .addComponent(btnMantFun, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnMantMod, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnMantAAut, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnAdminAAut, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        pnlAdminLayout.setVerticalGroup(
            pnlAdminLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAdminLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlAdminLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnMantFun, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnMantMod, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnMantAAut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnAdminAAut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlAdminLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnMantTurno, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnMantPer, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAsigTurno, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12))
        );

        btnMantFun.getAccessibleContext().setAccessibleDescription("");

        btnSalir.setFont(new java.awt.Font("sansserif", 0, 10)); // NOI18N
        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlAdmin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnSalir, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(btnConMar, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnTurno, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                    .addComponent(lblUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnMarca)
                    .addComponent(btnConMar)
                    .addComponent(btnTurno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlAdmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(btnSalir)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
/**
 * Comentario Esteban Varas
 * Al presionar el botón marcado crea una instancia de la clase marcado.
 * Recibe como parámetro de entrada el objeto funtemp que contiene los datos del funcionario.
 * Se carga y deja visible en pantalla la ventana Marcado con los datos del funcionario identificado,
 * previa evaluación en la clase Marcado si es ingreso o salida lo que el usuario debe marcar.
 * 
 * @param evt 
 */
    private void btnMarcaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMarcaActionPerformed
        Marcado marca = new Marcado(funtemp);
        marca.setVisible(true);

    }//GEN-LAST:event_btnMarcaActionPerformed
/**
 * Comentado por Esteban Varas
 * Al presionar botón Historial Marcado se crea una instancia de la clase ConsultaMAr.
 * Recibe como parámetro de entrada el objeto funtemp que contiene los datos del funcionario.
 * Se carga y despliega en pantalla la ventana ConsultaMAr el registro de marcado del funcionario identificado.
 * 
 * @param evt 
 */
    private void btnConMarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConMarActionPerformed
        ConsultaMAr conm= new ConsultaMAr(funtemp);
        conm.setVisible(true);
    }//GEN-LAST:event_btnConMarActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        System.exit(0);
        
    }//GEN-LAST:event_btnSalirActionPerformed

    private void btnMantTurnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMantTurnoActionPerformed
        TurnosMANT turm = new TurnosMANT();
        turm.setVisible(true);
    }//GEN-LAST:event_btnMantTurnoActionPerformed
/**Comentado por Esteban Varas
 * Al presionar el botón Asignación de Turnos (btnAsigTurnos) se crea el objeto astur,
 * que es una instancia de la clase TurnoASIGNA.
 * Posteriormente se despliega en pantalla la ventana TurnoASIGNA
 * @param evt 
 */
    private void btnAsigTurnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAsigTurnoActionPerformed
        TurnoASIGNA astur = new TurnoASIGNA();
        astur.setVisible(true);
    }//GEN-LAST:event_btnAsigTurnoActionPerformed
/**Comentado por Esteban Varas
 * Al presionar el botón Mantenedor de Módulos (btnMantMod) se crea una instancia de la clase
 * ModulosMANT.
 * Posteriormente se despliega en pantalla la ventana del Mantenedor de Módulos.
 * @param evt 
 */
    private void btnMantModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMantModActionPerformed
        ModulosMANT mantmod = new ModulosMANT();
        mantmod.setVisible(true);
    }//GEN-LAST:event_btnMantModActionPerformed
/**
 * Comentado por Esteban Varas
 * Al presionar botón Mantenedor de Funcionarios (btnMantFun) se crea una instancia de
 * la clase FuncionariosMANT.
 * Posteriormente se despliega en pantalla la ventana FuncionariosMANT con el Mantenedor
 * de Funcionarios.
 * @param evt 
 */
    
    private void btnMantFunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMantFunActionPerformed
       FuncionariosMANT mantfun = new FuncionariosMANT();
       mantfun.setVisible(true);
    }//GEN-LAST:event_btnMantFunActionPerformed
/**
 * Comentado por Esteban Varas
 * Al presionar botón btnTurno se crea una instancia de la clase ConsultaTUR,
 * recibiendo como parámetro de entrada el objeto funtemp que contiene los datos
 * del funcionario identificado.
 * Posteriormente despliega en pantalla la ventana ConsultaTUR con el detalle de los
 * turnos para el funcionario.
 * @param evt 
 */
    private void btnTurnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTurnoActionPerformed
        ConsultaTUR ct = new ConsultaTUR(funtemp);
        ct.setVisible(true);
    }//GEN-LAST:event_btnTurnoActionPerformed
/**
 * 
 * Comentado por Esteban Varas
 * Al presionar botón Reporte Mensual Asistencia (btnReporte):
 * 1. Se crea una instancia de la clase Calendar(c)
 * 2. A la variable string RESULT se le asigna la ubicación y nombre del reporte con fecha.
 * 3. Se crea un objeto de la clase FormatosPDF (fmt) y un objeto de la clase Document (document)
 * 4. Se crea una instancia de la clase PDFWriter, la que recibe como parámetro el objeto document seteandole el tamaño a carta,
 * luego se abre el objeto document.
 * 5. Se crea una lista  de Funcionarios la cual es cargada con los datos obtenidos del método findall de la clase FuncionarioDAO.
 * 6. Se utiliza un ciclo for anidado dentro de otro para agregar los datos de marcación por cada funcionario.
 * Para acceder a los datos de marcación se crea una lista de Marcación, la cual es cargada con los datos obtenidos del método findall de la clase MarcacionDAO
 * Al final del ciclo se produce un salto de página
 * 
 * @param evt 
 */
    
    private void btnReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReporteActionPerformed
        try {
            Calendar c = Calendar.getInstance();
            String RESULT = System.getProperty("user.home")+"\\Desktop\\"+"Asistencia "+  c.get(Calendar.MONTH)+"-"+c.get(Calendar.YEAR)+".pdf";
            FormatosPDF fmt = new FormatosPDF();
            Document document = new Document(PageSize.LETTER);
            PdfWriter.getInstance(document, new FileOutputStream(RESULT));
            document.open();
            java.util.List<Funcionario> funcionarios = FactoryDAO.getInstance().getDataFun().findAll();
            for (Funcionario fun: funcionarios)
            {
                document.add(fmt.addHeader());
                document.add(fmt.addTitulo("Reporte de Asistencia Mensual"));
                document.add(fmt.addSubTitulo("Funcionario: "+fun.getNombres()+" - Rut: "+fun.getRut_funcionario()));
                PdfPTable tabla = new PdfPTable(3);
                tabla.setTotalWidth(300);
                tabla.setLockedWidth(true);
                tabla.addCell(fmt.addCellHead("Fecha"));
                tabla.addCell(fmt.addCellHead("Entrada"));
                tabla.addCell(fmt.addCellHead("Salida"));
                tabla.getDefaultCell().setBackgroundColor(null);
                // There are three special rows
                tabla.setHeaderRows(1);
                
                java.util.List<Marcacion> marcas = FactoryDAO.getInstance().getDataMar().findAll(fun, c.get(Calendar.YEAR) +"-"+c.get(Calendar.MONTH)+"-1", c.get(Calendar.YEAR) +"-"+c.get(Calendar.MONTH)+"-31");
                for(Marcacion m : marcas)
                   {
                       SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
                       tabla.addCell(fmt.addCell(sdf.format(m.getFecha()).toString()));
                       tabla.addCell(fmt.addCell(m.getH_entrada().toString()));
                       tabla.addCell(fmt.addCell(m.getH_salida().toString()));
                   }
                document.add(tabla);
                document.newPage();
            }

            document.close();

         }
         catch (DocumentException ex){
                   Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
         }   
         catch (FileNotFoundException ex) {
                   Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
         }
         catch (IOException ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
         } 
    }//GEN-LAST:event_btnReporteActionPerformed

    private void btnMantAAutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMantAAutActionPerformed
        
    }//GEN-LAST:event_btnMantAAutActionPerformed

    private void btnAdminAAutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdminAAutActionPerformed
        AusenciasADM ausa = new AusenciasADM();
        ausa.setVisible(true);
    }//GEN-LAST:event_btnAdminAAutActionPerformed

    private void btnMantPerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMantPerActionPerformed
        PerfilesMANT perm = new PerfilesMANT();
        perm.setVisible(true);
    }//GEN-LAST:event_btnMantPerActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Menu(funtemp).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdminAAut;
    private javax.swing.JButton btnAsigTurno;
    private javax.swing.JButton btnConMar;
    private javax.swing.JButton btnMantAAut;
    private javax.swing.JButton btnMantFun;
    private javax.swing.JButton btnMantMod;
    private javax.swing.JButton btnMantPer;
    private javax.swing.JButton btnMantTurno;
    private javax.swing.JButton btnMarca;
    private javax.swing.JButton btnReporte;
    private javax.swing.JButton btnSalir;
    private javax.swing.JButton btnTurno;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel lblUsuario;
    private javax.swing.JPanel pnlAdmin;
    // End of variables declaration//GEN-END:variables
}
